package com.bird.server.combine.impl;

import com.bird.domain.dto.MainPageInfoDTO;
import com.bird.domain.dto.Result;
import com.bird.domain.entity.HeadLine;
import com.bird.domain.entity.ShopCategory;
import com.bird.server.combine.HeadLineShopCategoryCombineService;
import com.bird.server.solo.HeadLineService;
import com.bird.server.solo.ShopCategoryService;
import org.simpleFramework.core.annotation.Service;
import org.simpleFramework.core.inject.annotation.Autowired;

import java.util.List;

/**
 * @Author: sijunqiang
 * @Date: 2020/3/29 18:00
 * @Description:
 */
@Service
public class HeadLineShopCategoryCombineServiceImpl implements HeadLineShopCategoryCombineService {
    @Autowired
    private HeadLineService headLineService;
    @Autowired
    private ShopCategoryService shopCategoryService;


    /**
     * 获取商品和头条的列表数据
     *
     * @return s
     */
    @Override
    public Result<MainPageInfoDTO> getMainPageInfo() {

        ThreadLocal<Object> threadLocal = new ThreadLocal<>();
        System.out.println(threadLocal.get());


        //获取头条列表
        HeadLine headLineCondition = new HeadLine();
        headLineCondition.setEnableStatus(1);
        Result<List<HeadLine>> headLineList = headLineService.queryHeadLine(headLineCondition, 1, 4);

        //获取店铺的类别列表
        ShopCategory shopCategoryCondition = new ShopCategory();
        Result<List<ShopCategory>> shopCategoryList = shopCategoryService.queryShopCategory(shopCategoryCondition, 1, 100);

        //合并结果并返回
        Result<MainPageInfoDTO> mainPageInfoDtoResult = mergeMainPageInfoResult(headLineList, shopCategoryList);
        return mainPageInfoDtoResult;
    }


    /**
     * 将头条列表和商品列表合并并返回
     *
     * @param headLineResult
     * @param shopCategoryResult
     * @return
     */
    private Result<MainPageInfoDTO> mergeMainPageInfoResult(Result<List<HeadLine>> headLineResult, Result<List<ShopCategory>> shopCategoryResult) {
        return null;
    }


}
